package com.bihu.bihudemo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bihu.bihudemo.dao.FriendDao;
import com.bihu.bihudemo.entity.Friend;
import com.bihu.bihudemo.entity.User;
import com.bihu.bihudemo.service.FriendService;
import com.bihu.bihudemo.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * (Friend)表服务实现类
 *
 * @author makejava
 * @since 2020-07-20 15:19:29
 */
@Service("friendService")
public class FriendServiceImpl extends ServiceImpl<FriendDao, Friend> implements FriendService {

    @Resource
    FriendDao friendDao;
    @Resource
    UserService userService;
    /**
     * 根据用户ID查询用户好友
     * @param uid 用户ID
     * @return
     * */

    @Override
    public List<User> getFriends(Integer uid) {
        List<Integer> Idlist = friendDao.getFrinedID(uid);

        ArrayList<User> list = new ArrayList<>();
        for(Integer id:Idlist){
            User user = userService.getById(id);
            user.setPassword("就不告诉你");
            list.add(user);
        }
        return list;
    }
}